﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:data="clr-namespace:Tomers.WPF.DataVirtualization.Data"
             x:Name="userControl" x:Class="SqlExport.View.DataViewListView"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300"
             DataContext="{Binding DataViewViewModel, Source={StaticResource Locator}}">
    <UserControl.Resources>
        <ResourceDictionary>
            <!-- ColumnHeader template to show up and down arrow when sorted -->
            <DataTemplate x:Key="ListViewColumnHeaderTemplate">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <ContentPresenter ContentTemplate="{x:Null}" />
                    <Path x:Name="Path" Grid.Column="1" Fill="Black" Margin="4,0,2,0" VerticalAlignment="Center" />
                </Grid>
                <!--<DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding (dv:GridViewSort.SortOrder), RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type GridViewColumnHeader}}}" Value="None">
                        <Setter TargetName="Path" Property="Visibility" Value="Collapsed" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding (dv:GridViewSort.SortOrder), RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type GridViewColumnHeader}}}" Value="Ascending">
                        <Setter TargetName="Path" Property="Data" Value="M 0 4 L 4 0 L 8 4 Z" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding (dv:GridViewSort.SortOrder), RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type GridViewColumnHeader}}}" Value="Descending">
                        <Setter TargetName="Path" Property="Data" Value="M 0 0 L 4 4 L 8 0 Z" />
                    </DataTrigger>
                </DataTemplate.Triggers>-->
            </DataTemplate>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.Resources>
            <CollectionViewSource x:Key="ListViewViewSource"
                          CollectionViewType="{x:Type data:DataVirtualizationCollectionView}"
                          Source="{Binding ItemsSource}" />
        </Grid.Resources>
        <ListView ItemsSource="{Binding Source={StaticResource ListViewViewSource}}" VirtualizingStackPanel.IsVirtualizing="True"
                VirtualizingStackPanel.VirtualizationMode="Recycling">
            <ListView.View>
                <GridView x:Name="grdView">
                </GridView>
            </ListView.View>
        </ListView>
    </Grid>
</UserControl>
